<?php

namespace app\admin\controller;

use think\Request;
use think\Db;
use think\Validate;

class Node extends AdminController
{
    public function index()
    {
        $list = Db::name('node')
                ->field(['id', 'mname', 'name', 'aname', 'status'])
                ->select();
//        echo db('table')->getlastsql();
        return view('node/index', [
            'list' => $list
        ]);
    }

    public function add()
    {
        return view('admin@node/add');
    }

    public function doAdd(Request $request)
    {
        $data = input('post.');

        $result = Db::name('node')->insert($data);

        if ($result > 0) {
            return $this->success('添加成功!', '/admin/role/index');
        }else{
            return $this->error('添加失败!');
        }
    }

}